package fr.uparis10.miage.m1p1.employes;

import java.util.Date;
import java.util.Calendar;

import fr.uparis10.miage.m1p1.core.Employe;

public abstract class Manager extends Employe {
	private final static double DEFAULT_BUDGET = 100000;
	
	protected double budgetAnnuel;
	protected Date dateNomination;

	/**
	 * Default constructor.
	 * It is assigned the default budget, and the assignment start date is set
	 * current date&time.
	 */
	public Manager() {
		super();
		this.budgetAnnuel = DEFAULT_BUDGET;
		this.dateNomination = Calendar.getInstance().getTime();
	}
	
	public Manager(int preferedEmplId, long preferedNumSS) {
		super(preferedEmplId, preferedNumSS);		
	}

	public Manager(int preferedEmplId, long preferedNumSS, Date joinDate) {
		super(preferedEmplId, preferedNumSS, joinDate);
	}
	
	/**
	 * The constructor that initializes the Manager object with his default budget
	 * and assignment/start date.
	 * @param budget
	 * @param startDate
	 */
	public Manager(int preferedEmplId, long preferedNumSS, Date joinDate, double budget, Date dateNomination) {
		super(preferedEmplId, preferedNumSS, joinDate);
		this.budgetAnnuel = budget;
		this.dateNomination = dateNomination;
	}

	/**
	 * This abstract method must return the budget it is asked, or less.
	 * It may return "0" in case the budget is not approved at all. 
	 * @param requestedBudget: the budget requested
	 * @param reason: the Reason for which the Budget is requested
	 * @return an double representing the approved budget
	 */
	public abstract double requestBudget(double requestedBudget, String reason);
	
	/**
	 * Adds some more budget
	 * @param budget
	 */
	public void addBudget(double budget) {
		budgetAnnuel += budget;
	}
	
	/**
	 * Sets all the budget to a new value.
	 * @param newBudget
	 */
	public void setBudget(double newBudget) {
		budgetAnnuel = newBudget;
	}
	
	/**
	 * Does this manager have the needed budget?
	 * @param budget
	 * @return
	 */
	public boolean hasBudget(double budget) {
		return budgetAnnuel >= budget;
	}
	
	/**
	 * The Manager has a new assignment, so give him a new Budget and start date 
	 * @param budget
	 * @param startDate
	 */
	public void newAssignment(double budget, Date startDate) {
		budgetAnnuel = budget;
		dateNomination = startDate;
	}
}



